home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 February
/
EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso
/
earcd
/
util4
/
0utils.lha
/
0Utils
/
VolName.data
< prev
next >
Wrap
Text File
|
1995-08-19
|
3KB
|
152 lines
#ifdef TPLTER
VolName = {
SHORT = {{ get the Volumename of a file }};
DESCRIPTION = {{
VolName gets a filename and evaluates its
Volumename.
If VOLUME is selected, we call GetNameFromLock
and evaluate the Volumename from that string
If DEVICE is selected, we try to get the
Devicename instead of the Volumename.
DEVICE hides VOLUME.
The resulting string is sent to STDOUT.
RESULT
the volumename of the file, or empty string
if information can not be found
}};
BUGS = {{
We use 'Lock' to check the file, so an exclusively
locked or non existant file is not recognized, if
one of the flags is given.
}};
EXAMPLES = {{
(we are assuming You use a unmodified Workbench)
>VolName ENV:Sys
ENV:
>VolName ENV:Sys VOLUME
Ram Disk:
>VolName ENV:Sys DEVICE
RAM:
}};
HISTORY = {{
08-02-95 b_noll created
11-02-95 b_noll enabled 'DEVICE/S', changed 'PHYSICAL' to 'VOLUME'
20-02-95 b_noll restructured source
21-02-95 b_noll added version/format-prefix/offset
20-03-95 b_noll added args diagnostics
19-08-95 b_noll created .data file
}};
Template = "FILE/A,VOLUME/S,DEVICE/S";
Arguments = {{
STRPTR file;
ULONG volume;
ULONG device;
}};
version = "1.3";
body = {{
APTR processwin;
struct Process *process;
STRPTR filename = argv->file;
//UBYTE buffer[MAXPATHLEN];
BPTR out;
out = Output();
if ((process = (struct Process *)FindTask(NULL))) {
processwin = process->pr_WindowPtr;
process->pr_WindowPtr = (APTR)-1;
} /* if */
if (argv->device || argv->volume || !*filename) {
BPTR lock;
//dolock:
if (lock = Lock(filename, SHARED_LOCK)) {
struct FileLock *fl;
struct DosList *dl;
fl = BADDR(lock);
dl = BADDR(fl->fl_Volume);
if (argv->device) {
struct MsgPort *mp;
mp = dl->dol_Task;
dl = LockDosList(LDF_DEVICES|LDF_READ);
while (dl = NextDosEntry(dl,LDF_DEVICES)) {
if (dl->dol_Task == mp) {
FPrintf(out, "%b:\n", dl->dol_Name);
out = 0;
break;
} /* if Found */
} /* while Searching */
UnLockDosList(LDF_DEVICES|LDF_READ);
} else {
FPrintf(out, "%b:\n", dl->dol_Name);
out = 0;
} /* if (!)Device */
UnLock (lock);
} /* if Lock */
} /* if DoLocking */
/* ---- Extract the Volumepart */
if (out) {
#ifdef ALPHA
UBYTE buffer[MAXPATHLEN];
if (SplitName(filename, ':', buffer, 0, MAXPATHLEN) != -1) {
FPrintf(out, "%s:\n", buffer);
out = 0;
// } else if (*filename) {
// filename = "";
// goto dolock;
} /* if */
#else
UBYTE c, *p;
for (p = filename; (c = *p) && c != ':'; ++p);
if (c) {
*p = 0;
FPrintf(out, "%s:\n", filename);
out = 0;
*p = ':';
// } else if (*filename) {
// filename = "";
// goto dolock;
} /* if */
#endif
} /* if */
//PutStr (":\n");
retval = out ? RETURN_WARN : RETURN_OK;
if (process != NULL) {
process->pr_WindowPtr = processwin;
} /* if */
}};
};
#endif